home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Samples / C++ / Direct3D / HDRLighting / GlareDefD3D.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-09-27  |  6.9 KB  |  315 lines

  1. // File provided by Masaki Kawase 
  2. // http://www.daionet.gr.jp/~masa/rthdribl/
  3.  
  4. // GlareDefD3D.h : Define glare information
  5. //
  6.  
  7. #ifndef _GLAREDEFD3DD3D_H_
  8. #define _GLAREDEFD3DD3D_H_
  9.  
  10. #include <d3dx9.h>
  11.  
  12.  
  13. //----------------------------------------------------------
  14. // Star generation
  15.  
  16. // Define each line of the star.
  17. typedef struct STARLINE
  18. {
  19.     int        nPasses ;
  20.     float    fSampleLength ;
  21.     float    fAttenuation ;
  22.     float    fInclination ;
  23.  
  24. } *LPSTARLINE ;
  25.  
  26.  
  27. // Simple definition of the star.
  28. typedef struct STARDEF
  29. {
  30.     TCHAR    *szStarName ;
  31.     int        nStarLines ;
  32.     int        nPasses ;
  33.     float    fSampleLength ;
  34.     float    fAttenuation ;
  35.     float    fInclination ;
  36.     bool    bRotation ;
  37.  
  38. } *LPSTARDEF ;
  39.  
  40.  
  41. // Simple definition of the sunny cross filter
  42. typedef struct STARDEF_SUNNYCROSS
  43. {
  44.     TCHAR    *szStarName ;
  45.     float    fSampleLength ;
  46.     float    fAttenuation ;
  47.     float    fInclination ;
  48.  
  49. } *LPSTARDEF_SUNNYCROSS ;
  50.  
  51.  
  52. // Star form library
  53. enum ESTARLIBTYPE
  54. {
  55.     STLT_DISABLE            = 0,
  56.  
  57.     STLT_CROSS,
  58.     STLT_CROSSFILTER,
  59.     STLT_SNOWCROSS,
  60.     STLT_VERTICAL,
  61.     NUM_BASESTARLIBTYPES,
  62.  
  63.     STLT_SUNNYCROSS            = NUM_BASESTARLIBTYPES,
  64.  
  65.     NUM_STARLIBTYPES,
  66. } ;
  67.  
  68.  
  69. //----------------------------------------------------------
  70. // Star generation object
  71.  
  72. class CStarDef
  73. {
  74. public:
  75.     TCHAR            m_strStarName[256] ;
  76.  
  77.     int                m_nStarLines ;
  78.     LPSTARLINE        m_pStarLine ;    // [m_nStarLines]
  79.     float            m_fInclination ;
  80.     bool            m_bRotation ;    // Rotation is available from outside ?
  81.  
  82. // Static library
  83. public:
  84.     static CStarDef        *ms_pStarLib ;
  85.     static D3DXCOLOR    ms_avChromaticAberrationColor[8] ;
  86.  
  87. // Public method
  88. public:
  89.     CStarDef() ;
  90.     CStarDef(const CStarDef& src) ;
  91.     ~CStarDef() ;
  92.  
  93.     CStarDef& operator =(const CStarDef& src) {
  94.         Initialize(src) ;
  95.         return *this ;
  96.     }
  97.  
  98.     HRESULT Construct() ;
  99.     void Destruct() ;
  100.     void Release() ;
  101.  
  102.     HRESULT Initialize(const CStarDef& src) ;
  103.  
  104.     HRESULT Initialize(ESTARLIBTYPE eType) {
  105.         return Initialize(ms_pStarLib[eType]) ;
  106.     }
  107.  
  108.     /// Generic simple star generation
  109.     HRESULT Initialize(const TCHAR *szStarName,
  110.                        int nStarLines,
  111.                        int nPasses,
  112.                        float fSampleLength,
  113.                        float fAttenuation,
  114.                        float fInclination,
  115.                        bool bRotation) ;
  116.  
  117.     HRESULT Initialize(const STARDEF& starDef)
  118.     {
  119.         return Initialize(starDef.szStarName,
  120.                           starDef.nStarLines,
  121.                           starDef.nPasses,
  122.                           starDef.fSampleLength,
  123.                           starDef.fAttenuation,
  124.                           starDef.fInclination,
  125.                           starDef.bRotation) ;
  126.     }
  127.  
  128.     /// Specific star generation
  129.     //  Sunny cross filter
  130.     HRESULT Initialize_SunnyCrossFilter(const TCHAR *szStarName = TEXT("SunnyCross"),
  131.                                         float fSampleLength = 1.0f,
  132.                                         float fAttenuation = 0.88f,
  133.                                         float fLongAttenuation = 0.95f,
  134.                                         float fInclination = D3DXToRadian(0.0f)) ;
  135.  
  136.  
  137. // Public static method
  138. public:
  139.     /// Create star library
  140.     static HRESULT InitializeStaticStarLibs() ;
  141.     static HRESULT DeleteStaticStarLibs() ;
  142.  
  143.     /// Access to the star library
  144.     static const CStarDef& GetLib(DWORD dwType) {
  145.         return ms_pStarLib[dwType] ;
  146.     }
  147.  
  148.     static const D3DXCOLOR& GetChromaticAberrationColor(DWORD dwID) {
  149.         return ms_avChromaticAberrationColor[dwID] ;
  150.     }
  151. } ;
  152.  
  153.  
  154.  
  155. //----------------------------------------------------------
  156. // Clare definition
  157.  
  158. // Glare form library
  159. enum EGLARELIBTYPE
  160. {
  161.     GLT_DISABLE                    = 0,
  162.  
  163.     GLT_CAMERA,
  164.     GLT_NATURAL,
  165.     GLT_CHEAPLENS,
  166.     //GLT_AFTERIMAGE,
  167.     GLT_FILTER_CROSSSCREEN,
  168.     GLT_FILTER_CROSSSCREEN_SPECTRAL,
  169.     GLT_FILTER_SNOWCROSS,
  170.     GLT_FILTER_SNOWCROSS_SPECTRAL,
  171.     GLT_FILTER_SUNNYCROSS,
  172.     GLT_FILTER_SUNNYCROSS_SPECTRAL,
  173.     GLT_CINECAM_VERTICALSLITS,
  174.     GLT_CINECAM_HORIZONTALSLITS,
  175.  
  176.     NUM_GLARELIBTYPES,
  177.     GLT_USERDEF                    = -1,
  178.     GLT_DEFAULT                    = GLT_FILTER_CROSSSCREEN,
  179. } ;
  180.  
  181.  
  182. // Simple glare definition
  183. typedef struct GLAREDEF
  184. {
  185.     TCHAR            *szGlareName ;
  186.     float            fGlareLuminance ;
  187.  
  188.     float            fBloomLuminance ;
  189.     float            fGhostLuminance ;
  190.     float            fGhostDistortion ;
  191.     float            fStarLuminance ;
  192.     ESTARLIBTYPE    eStarType ;
  193.     float            fStarInclination ;
  194.  
  195.     float            fChromaticAberration ;
  196.  
  197.     float            fAfterimageSensitivity ;    // Current weight
  198.     float            fAfterimageRatio ;            // Afterimage weight
  199.     float            fAfterimageLuminance ;
  200.  
  201. } *LPGLAREDEF ;
  202.  
  203.  
  204. //----------------------------------------------------------
  205. // Glare definition
  206.  
  207. class CGlareDef
  208. {
  209. public:
  210.     TCHAR        m_strGlareName[256] ;
  211.  
  212.     float        m_fGlareLuminance ;        // Total glare intensity (not effect to "after image")
  213.     float        m_fBloomLuminance ;
  214.     float        m_fGhostLuminance ;
  215.     float        m_fGhostDistortion ;
  216.     float        m_fStarLuminance ;
  217.     float        m_fStarInclination ;
  218.  
  219.     float        m_fChromaticAberration ;
  220.  
  221.     float        m_fAfterimageSensitivity ;    // Current weight
  222.     float        m_fAfterimageRatio ;        // Afterimage weight
  223.     float        m_fAfterimageLuminance ;
  224.  
  225.     CStarDef    m_starDef ;
  226.  
  227. // Static library
  228. public:
  229.     static CGlareDef    *ms_pGlareLib ;
  230.  
  231. // Public method
  232. public:
  233.     CGlareDef() ;
  234.     CGlareDef(const CGlareDef& src) ;
  235.     ~CGlareDef() ;
  236.  
  237.     CGlareDef& operator =(const CGlareDef& src) {
  238.         Initialize(src) ;
  239.         return *this ;
  240.     }
  241.  
  242.     HRESULT Construct() ;
  243.     void Destruct() ;
  244.     void Release() ;
  245.  
  246.     HRESULT Initialize(const CGlareDef& src) ;
  247.  
  248.     HRESULT Initialize(const TCHAR *szStarName,
  249.                        float fGlareLuminance,
  250.                        float fBloomLuminance,
  251.                        float fGhostLuminance,
  252.                        float fGhostDistortion,
  253.                        float fStarLuminance,
  254.                        ESTARLIBTYPE eStarType,
  255.                        float fStarInclination,
  256.                        float fChromaticAberration,
  257.                        float fAfterimageSensitivity,    // Current weight
  258.                        float fAfterimageRatio,            // After Image weight
  259.                        float fAfterimageLuminance) ;
  260.  
  261.     HRESULT Initialize(const GLAREDEF& glareDef)
  262.     {
  263.         return Initialize(glareDef.szGlareName,
  264.                           glareDef.fGlareLuminance,
  265.                           glareDef.fBloomLuminance,
  266.                           glareDef.fGhostLuminance,
  267.                           glareDef.fGhostDistortion,
  268.                           glareDef.fStarLuminance,
  269.                           glareDef.eStarType,
  270.                           glareDef.fStarInclination,
  271.                           glareDef.fChromaticAberration,
  272.                           glareDef.fAfterimageSensitivity,
  273.                           glareDef.fAfterimageRatio,
  274.                           glareDef.fAfterimageLuminance) ;
  275.     }
  276.  
  277.     HRESULT Initialize(EGLARELIBTYPE eType) {
  278.         return Initialize(ms_pGlareLib[eType]) ;
  279.     }
  280.  
  281.  
  282. // Public static method
  283. public:
  284.     /// Create glare library
  285.     static HRESULT InitializeStaticGlareLibs() ;
  286.     static HRESULT DeleteStaticGlareLibs() ;
  287.  
  288.     /// Access to the glare library
  289.     static const CGlareDef& GetLib(DWORD dwType) {
  290.         return ms_pGlareLib[dwType] ;
  291.     }
  292. } ;
  293.  
  294.  
  295. //----------------------------------------------------------
  296. // Dummy to generate static object of glare
  297. class __CGlare_GenerateStaticObjects
  298. {
  299. public:
  300.     __CGlare_GenerateStaticObjects() {
  301.         CStarDef::InitializeStaticStarLibs() ;
  302.         CGlareDef::InitializeStaticGlareLibs() ;
  303.     }
  304.  
  305.     ~__CGlare_GenerateStaticObjects() {
  306.         CGlareDef::DeleteStaticGlareLibs() ;
  307.         CStarDef::DeleteStaticStarLibs() ;
  308.     }
  309.  
  310.     static __CGlare_GenerateStaticObjects ms_staticObject ;
  311. } ;
  312.  
  313.  
  314. #endif    // #ifndef _GLAREDEFD3DD3D_H_
  315.